cmake_minimum_required(VERSION 3.5)


# 这里是为了避免编译时改变源程序
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES  ON)

if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  message(SEND_ERROR "In-source builds are not allowed.")
endif ()

# 生成的文件有颜色？
# 似乎与编译结果关系不大，忽略，暂时留在这里
set(CMAKE_COLOR_MAKEFILE   ON)

# 设定cmake文件的存放目录
# 目前没有使用，暂时保留
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)


set(BUILD_TYPE_RELEASE TRUE)



SET (THIS_COM "${PROJECT_SOURCE_DIR}/" )
#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
#        ${CMAKE_BINARY_DIR}/Configuration.h)

if(CMAKE_SYSTEM_NAME MATCHES Linux)
  set(CMAKE_CXX_FLAGS "-O3 -no-pie -march=native -ggdb -Wall \
-Wextra -Wcast-align -Wdisabled-optimization -Wformat=2 \
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
 -Wshadow -Wsign-promo -Werror")
elseif(APPLE)
    set(CMAKE_CXX_FLAGS "-O3 -march=native -ggdb -Wall \
-Wextra -Wcast-align -Wdisabled-optimization -Wformat=2 \
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
-Wshadow -Wsign-promo")
include_directories("/usr/local/include/")   # lcm includes
endif()

set(CMAKE_C_FLAGS "-O3  -ggdb  -march=native -std=gnu99 -I.")
message(WARNING "not set to mini cheetah build.  this won't work on the robot!")

set(CMAKE_CXX_STANDARD 14)

#add_subdirectory(robot)
#add_subdirectory(third-party)
#add_subdirectory(common)
add_subdirectory(test)
#add_subdirectory(user)
#add_subdirectory(footplan-viewer)
